home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 116_01.zip / SAVEADV.C < prev    next >
Text File  |  1993-06-19  |  768b  |  38 lines

  1.  
  2.  /* SAVEADV.C  no mods for V 1.43 
  3.  */
  4. #include "advent.h"
  5.  
  6. main()
  7. {
  8.     /*
  9.         save adventure game
  10.     */
  11.     char *sptr;
  12.     int savefd;
  13.     char username[13];
  14.  
  15.     printf("What do you want to call the saved game? ");
  16.     scanf("%s",username);
  17.     strcat(username,".adv");
  18.     if ((savefd=fcreat(username,dbuff)) == -1) {
  19.         printf("sorry, I can't create the file...\n");
  20.         exit();
  21.     }
  22.     for (sptr=&turns; sptr<&lastglob; sptr++) {
  23.         if (putc(*sptr,dbuff) == -1) {
  24.             printf("write error on save file...\n");
  25.             exit();
  26.         }
  27.     }
  28.     if (fflush(dbuff) == -1) {
  29.         printf("flush error on save file...\n");
  30.         exit();
  31.     }
  32.     if (close(savefd) == -1) {
  33.         printf("can't close save file...\n");
  34.         exit();
  35.     }
  36.     printf("OK -- \"C\" you later...\n");
  37. }
  38.